<script setup lang="ts">
import { onMounted } from 'vue';
import { useRoute } from 'vue-router';
import { adaptFontSize } from './utils/mobile';
import TabBar from './components/TabBar.vue';

const route = useRoute();

// 初始化移动端适配
onMounted(() => {
  // 设置基础字体大小为16px
  adaptFontSize(16);
  
  // 监听窗口大小变化
  window.addEventListener('resize', () => {
    adaptFontSize(16);
  });
});
</script>

<template>
  <div class="app-container">
    <div class="page-content">
      <!-- 路由视图 -->
      <router-view v-slot="{ Component }">
        <transition name="fade" mode="out-in">
          <component :is="Component" />
        </transition>
      </router-view>
    </div>
    
    <!-- 底部导航栏 -->
    <TabBar />
  </div>
</template>

<style>
/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
  background-color: #f5f5f5;
  color: #333;
}

body {
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.app-container {
  position: relative;
  width: 100%;
  min-height: 100vh;
}

.page-content {
  padding-bottom: 50px; /* TabBar的高度 */
}

/* 路由过渡动画 */
.fade-enter-active,
.fade-leave-active {
  transition: opacity 0.2s;
}

.fade-enter-from,
.fade-leave-to {
  opacity: 0;
}
</style>
